package com.fly.caihong.utils;

import android.content.Context;
import android.os.Environment;
import android.os.SystemClock;

import java.io.File;

public class AppConfig {

    //app本地数据配置文件路径
    public static final String APP_JSON_PATH = Environment.getExternalStorageDirectory() + "/caihong/app.json";
    //屏幕宽度
    public static final int SCREEN_WIDTH = ScreenUtils.getScreenWidth();
    //屏幕高度
    public static final int SCREEN_HEIGHT = ScreenUtils.getScreenHeight();

    //快速点击
    private static final long[] mHits = new long[2];

    /**
     * 获取应用分类缓存目录
     *
     * @param context
     * @param type
     * @return
     */
    public static String getAppCacheDir(Context context, String type) {
        String cacheFile = "";
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            cacheFile = context.getApplicationContext().getExternalCacheDir() + File.separator + type;
        }
        return cacheFile;
    }

    /**
     * 是否快速点击了2次
     *
     * @return
     */
    public static boolean isQuickClick2Times() {
        System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
        mHits[mHits.length - 1] = SystemClock.uptimeMillis();
        return mHits[0] >= (SystemClock.uptimeMillis() - 500);
    }

}
